package io.scnb.lesson003.demo1.test5;

import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
public class UserRegisterListener {

    @EventListener
    @Order(1)
    public void sendMail(UserRegisterEvent event){
        System.out.println(String.format("【%s】，用户【%s】发送注册成功的邮件", Thread.currentThread(), event.getUsername()));
    }

    @EventListener
    @Order(0)
    public void sendCoupon(UserRegisterEvent event) {
        System.out.println(String.format("【%s】，用户【%s】发送优惠券", Thread.currentThread(), event.getUsername()));
    }
}
